home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / pas / swag / win_os2.swg / 0031_CTL3D And BORDLG mix.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-24  |  8KB  |  171 lines

  1. {
  2. Some time back, I asked if it was possible to combine CTL3D with BORDLG,
  3. with the resounding opinion that it wasn't possible to go all the way
  4. and provide a 3d dialog border, although you could have 3d controls
  5. in a bordlg using the CTL3dSubClassDlg command.
  6.  
  7. After much head scratching and many false starts, you'll find that
  8. the below unit provides just what I'd been trying to do - i.e.
  9. fully combine BORDLG with CTL3D.
  10.  
  11. Basically, all you have to do is add BWCC3D to the USES clause of
  12. your main source file and add the command KILLBWCCCTL3D just before
  13. your program shuts down - for example before HALT instructions
  14. or before <MYAPP>.DONE seems to work.  You'll then have to run
  15. Resource Workshop, change the class of your dialogues
  16. from BORDLG to BORDLG_CTL3D and make sure you include CTL3D.DLL
  17. with your application.  BORDLG_CTL3D dialogues have the CS_SAVEBITS
  18. flag set, so they save the area beneath them like standard & CTL3D
  19. dialogue boxes.
  20.  
  21. Comments and suggestions appreciated, and appologies for the way
  22. that this message may have been chopped up.
  23.  
  24. Neil Gorin
  25. neil.gorin@nildram.com
  26.  
  27. ================== BWCC3D.PAS ====================}
  28.  
  29. Unit BWCC3d;
  30.  
  31. {********************************************************************}
  32. { BWCC3D.TPW - Replaces CTL3D.TPW                                    }
  33. { Based on CTL3D.PAS by Andreas Furrer                               }
  34. {                                                                    }
  35. { Created 2nd June 1994, Neil Gorin                                  }
  36. { Internet: neil.gorin@nildram.com                                   }
  37. { Post: 4 Rookwood Drive, Stevenage, Herts. SG2 8PJ ENGLAND          }
  38. { Telephone: (UK) +44 438 362671   (GMT Evenings and Weekends only)  }
  39. {                                                                    }
  40. { Purpose:                                                           }
  41. {                                                                    }
  42. { Allows CTL3D frame and effects on BORDLG's                         }
  43. {                                                                    }
  44. { Use:                                                               }
  45. {                                                                    }
  46. { 1: If you currently have CTL3D in your "uses" clause, remove it as }
  47. {    BWCC3D contains all the functionality of CTL3D.  Remove any     }
  48. {    references to CTL3DREGISTER, CTL3DUNREGISTER and                }
  49. {    CTL3DAUTOSUBCLASS from your program.                            }
  50. {                                                                    }
  51. { 2: Add BWCC3D to your "uses" clause.                               }
  52. {                                                                    }
  53. { 3: Where your program ends, add the command: KILLBWCCCTL3D         }
  54. {    For example, if an ObjectWindows app, before <APPNAME>.DONE     }
  55. {                                                                    }
  56. { 4: With Resource Workshop, change the class name of all your       }
  57. {    dialogues from BORDLG to BORDLG_CTL3D                           }
  58. {                                                                    }
  59. {********************************************************************}
  60. {                                                                    }
  61. { Tips:                                                              }
  62. {                                                                    }
  63. {    o  If you have version 2.0 of BWCC.DLL (as supplied with BC++4) }
  64. {       you can change the line reading:                             }
  65. {                                                                    }
  66. {           GetClassInfo(Hinstance,'Bordlg',Gorin);                  }
  67. {       to  GetClassInfo(Hinstance,'Bordlg_gray',Gorin);             }
  68. {                                                                    }
  69. {       This will result in a solid grey background as opposed to    }
  70. {       to the normal stippled BWCC effect.                          }
  71. {                                                                    }
  72. {    o  If you only want the 3D effect frame and not the 3D          }
  73. {       controls, remove the line reading:                           }
  74. {                                                                    }
  75. {           WM_INITDIALOG: CTL3DSUBCLASSDLG(Hwindow,CTL3d_ALL);      }
  76. {                                                                    }
  77. {********************************************************************}
  78. { Your comments are welcome - No strings are attached to the use or  }
  79. { distribution of this file.                                         }
  80. {********************************************************************}
  81.  
  82. Interface
  83. Uses Wintypes,winprocs,bwcc,ctl3d;
  84.  
  85. const Ctl3d_Buttons      = $0001;
  86.       Ctl3d_Listboxes    = $0002;
  87.       Ctl3d_Edits        = $0004;
  88.       Ctl3d_Combos       = $0008;
  89.       Ctl3d_StaticTexts  = $0010;
  90.       Ctl3d_StaticFrames = $0020;
  91.       Ctl3d_All          = $ffff;
  92.  
  93. function Ctl3dGetVer : word;
  94. function Ctl3dSubclassDlg(HWindow : HWnd; GrBits : word) : bool;
  95. function Ctl3dSubclassDlgEx(HWindow : HWnd; GrBits : word) : bool;
  96. function Ctl3dSubclassCtl(HWindow : HWnd) : bool;
  97. function Ctl3dCtlColor(DC : HDC; Color : TColorRef) : HBrush;
  98. function Ctl3dEnabled : bool;
  99. function Ctl3dColorChange : bool;
  100. function Ctl3dRegister(Instance : THandle) : bool;
  101. function Ctl3dUnregister(Instance : THandle) : bool;
  102. function Ctl3dAutoSubclass(Instance : THandle) : bool;
  103. function Ctl3dCtlColorEx(Message, wParam : word;
  104.                          lParam : longint) : HBrush;
  105. function Ctl3dDlgFramePaint(Hwindow:Hwnd; Message, wparam:word;
  106.                             Lparam:Longint):Longint;
  107. Procedure KillBwccCtl3d;
  108.  
  109. Implementation
  110.  
  111. function Ctl3dGetVer;       external 'Ctl3d' index 1;
  112. function Ctl3dSubclassDlg;  external 'Ctl3d' index 2;
  113. function Ctl3dSubclassCtl;  external 'Ctl3d' index 3;
  114. function Ctl3dCtlColor;     external 'Ctl3d' index 4;
  115. function Ctl3dEnabled;      external 'Ctl3d' index 5;
  116. function Ctl3dColorChange;  external 'Ctl3d' index 6;
  117. function Ctl3dRegister;     external 'Ctl3d' index 12;
  118. function Ctl3dUnregister;   external 'Ctl3d' index 13;
  119. function Ctl3dAutoSubclass; external 'Ctl3d' index 16;
  120. function Ctl3dCtlColorEx;   external 'Ctl3d' index 18;
  121. function Ctl3dDlgFramePaint;external 'Ctl3d' index 20;
  122. function Ctl3dSubclassDlgEx;external 'Ctl3d' index 21;
  123.  
  124.  
  125. Procedure KillBwccCtl3d;
  126. {********************************}
  127. { It is ESSENTIAL that you call  }
  128. { this before your program ends  }
  129. { as otherwise your User Heap    }
  130. { will gradually disappear!      }
  131. {********************************}
  132. begin
  133.      UnRegisterclass('BORDLG_CTL3D',hinstance);
  134.      CTL3DUnregister(Hinstance);
  135. end;
  136.  
  137. function Ctl3dBWCC(HWindow: hwnd; Message, WParam: word;
  138.                    LParam: longint): longint; export;
  139. {***********************************}
  140. { Takes control before the          }
  141. { standard BWCCDEFDLGPROC to        }
  142. { paint frame and subclass controls }
  143. { will gradually disappear!         }
  144. {***********************************}
  145. Const WM_PAINTIT=15000;
  146. var tms:tmsg;
  147. begin
  148.     If PeekMessage(tms,Hwindow,WM_Paintit,WM_Paintit,PM_REMOVE) then
  149.                                     Ctl3dDlgFramePaint(Hwindow,0,0,0);
  150.     Case message of
  151.        WM_SETTEXT,
  152.        WM_NCPAINT,
  153.        WM_NCACTIVATE: PostMessage(HWindow,WM_PAINTIT,0,0);
  154.        WM_INITDIALOG: CTL3DSUBCLASSDLG(Hwindow,CTL3d_ALL);
  155.     end;
  156.     Ctl3dBwcc:=BWCCDEFDLGPROC(Hwindow,message,wparam,lparam);
  157. end;
  158.  
  159. { This is run automatically *before* your program gets control }
  160.  
  161. var Gorin:TwndClass;
  162. begin
  163.      CTL3DRegister(Hinstance);
  164.      CTL3DAutoSubclass(Hinstance);
  165.      GetClassInfo(Hinstance,'Bordlg',Gorin);  {See above for BWCC 2.0 note}
  166.      Gorin.Style:=gorin.style or cs_savebits; {Saves bitmap of background}
  167.      Gorin.LPSZCLASSNAME:='BORDLG_CTL3D';
  168.      Gorin.lpfnwndproc:=@CTL3dBWCC;
  169.      Registerclass(gorin);
  170. end.
  171.